<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Axios 简化测试</title>
		<script src="../js/vue.js"></script>
		<script src="../js/axios.js"></script>
	</head>
	<body>
		<div id="a">
			<button @click="show()">按钮</button>
			<h2>{{msg}}</h2>
		</div>
		<script type="text/javascript">
			
			new Vue({
				el:"#a",
				data(){
					return{
						msg:""
					}
				},
				methods:{
					show(){
						/*简化方式1：*/
						axios.defaults.baseURL = "http://localhost:8080"
						axios.get("/web/hello")
						.then(promise => {
							this.msg = promise.data
						})
						
						async function getHello(){
						//let promise = await axios.get("web/hello")
							let {data:result} = await axios.get("web/hello")
							//this.msg=promise.data
							this.msg = result
						}
						getHello()
						async function getWeb(){
							let {data:result} = await axios.get("/web/hello")
							console.log(result)
							this.msg = result
						}
						getWeb()
						
					}
				}
			})
			
		</script>
		
	</body>
</html>
